ErinRoss_A01

Author

Erin Ross

1. Given the formulated question from the assignment description, you will now conduct EDA Checklist items 2-4. First, download 2002 and 2022 data for all sites in California from the EPA Air Quality Data website. Read in the data using data.table(). For each of the two datasets, check the dimensions, headers, footers, variable names and variable types. Check for any data issues, particularly in the key variable we are analyzing. Make sure you write up a summary of all of your findings.

Each dataset has 20 variables, including site codes/names/lat/lon, county codes/names, larger CBSA codes/names, state codes/names. There is also a daily number of observations (1), the daily mean PM2.5 concentration, daily air quality index (AQI) and the date for each day of the year. 2002 has 15976 observation, 2022 has 57775 observations.

There are no missing site IDs or numbers outside that look misentered (all are 8 digits). Daily AQI and PM2.5 concentrations don’t appear to have any missing values or unreasonable values.

setwd("/users/erinross/Desktop/PM566/DATA/")
PM.2002 <- read.csv("PM2.5_CA_2002.csv")
PM.2022 <- read.csv("PM2.5_CA_2022.csv")

str(PM.2002)
'data.frame':   15976 obs. of  20 variables:
 $ Date                          : chr  "01/05/2002" "01/06/2002" "01/08/2002" "01/11/2002" ...
 $ Source                        : chr  "AQS" "AQS" "AQS" "AQS" ...
 $ Site.ID                       : int  60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 ...
 $ POC                           : int  1 1 1 1 1 1 1 1 1 1 ...
 $ Daily.Mean.PM2.5.Concentration: num  25.1 31.6 21.4 25.9 34.5 41 29.3 15 18.8 37.9 ...
 $ UNITS                         : chr  "ug/m3 LC" "ug/m3 LC" "ug/m3 LC" "ug/m3 LC" ...
 $ DAILY_AQI_VALUE               : int  78 92 71 80 98 115 87 57 65 107 ...
 $ Site.Name                     : chr  "Livermore" "Livermore" "Livermore" "Livermore" ...
 $ DAILY_OBS_COUNT               : int  1 1 1 1 1 1 1 1 1 1 ...
 $ PERCENT_COMPLETE              : num  100 100 100 100 100 100 100 100 100 100 ...
 $ AQS_PARAMETER_CODE            : int  88101 88101 88101 88101 88101 88101 88101 88101 88101 88101 ...
 $ AQS_PARAMETER_DESC            : chr  "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" ...
 $ CBSA_CODE                     : int  41860 41860 41860 41860 41860 41860 41860 41860 41860 41860 ...
 $ CBSA_NAME                     : chr  "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" ...
 $ STATE_CODE                    : int  6 6 6 6 6 6 6 6 6 6 ...
 $ STATE                         : chr  "California" "California" "California" "California" ...
 $ COUNTY_CODE                   : int  1 1 1 1 1 1 1 1 1 1 ...
 $ COUNTY                        : chr  "Alameda" "Alameda" "Alameda" "Alameda" ...
 $ SITE_LATITUDE                 : num  37.7 37.7 37.7 37.7 37.7 ...
 $ SITE_LONGITUDE                : num  -122 -122 -122 -122 -122 ...
str(PM.2022)
'data.frame':   57775 obs. of  20 variables:
 $ Date                          : chr  "01/01/2022" "01/02/2022" "01/03/2022" "01/04/2022" ...
 $ Source                        : chr  "AQS" "AQS" "AQS" "AQS" ...
 $ Site.ID                       : int  60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 60010007 ...
 $ POC                           : int  3 3 3 3 3 3 3 3 3 3 ...
 $ Daily.Mean.PM2.5.Concentration: num  12.7 13.9 7.1 3.7 4.2 3.8 2.3 6.9 13.6 11.2 ...
 $ UNITS                         : chr  "ug/m3 LC" "ug/m3 LC" "ug/m3 LC" "ug/m3 LC" ...
 $ DAILY_AQI_VALUE               : int  52 55 30 15 18 16 10 29 54 47 ...
 $ Site.Name                     : chr  "Livermore" "Livermore" "Livermore" "Livermore" ...
 $ DAILY_OBS_COUNT               : int  1 1 1 1 1 1 1 1 1 1 ...
 $ PERCENT_COMPLETE              : num  100 100 100 100 100 100 100 100 100 100 ...
 $ AQS_PARAMETER_CODE            : int  88101 88101 88101 88101 88101 88101 88101 88101 88101 88101 ...
 $ AQS_PARAMETER_DESC            : chr  "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" "PM2.5 - Local Conditions" ...
 $ CBSA_CODE                     : int  41860 41860 41860 41860 41860 41860 41860 41860 41860 41860 ...
 $ CBSA_NAME                     : chr  "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" "San Francisco-Oakland-Hayward, CA" ...
 $ STATE_CODE                    : int  6 6 6 6 6 6 6 6 6 6 ...
 $ STATE                         : chr  "California" "California" "California" "California" ...
 $ COUNTY_CODE                   : int  1 1 1 1 1 1 1 1 1 1 ...
 $ COUNTY                        : chr  "Alameda" "Alameda" "Alameda" "Alameda" ...
 $ SITE_LATITUDE                 : num  37.7 37.7 37.7 37.7 37.7 ...
 $ SITE_LONGITUDE                : num  -122 -122 -122 -122 -122 ...
summary(PM.2002$Site.ID)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
60010007 60290014 60590007 60549600 60731002 61131003 
summary(PM.2022$Site.ID)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
60010007 60311004 60631007 60571692 60771003 61131003 
summary(PM.2002$DAILY_AQI_VALUE)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00   29.00   50.00   53.68   69.00  176.00 
summary(PM.2022$DAILY_AQI_VALUE)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00   18.00   29.00   32.95   45.00  353.00 
summary(PM.2002$Daily.Mean.PM2.5.Concentration)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00    7.00   12.00   16.12   20.50  104.30 
summary(PM.2022$Daily.Mean.PM2.5.Concentration)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -2.200   4.200   7.000   8.574  10.900 302.500 
2. Combine the two years of data into one data frame. Use the Date variable to create a new column for year, which will serve as an identifier. Change the names of the key variables so that they are easier to refer to in your code.
PM.All <- rbind(PM.2002,PM.2022)
library(lubridate)

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
PM.All$Date <- mdy(PM.All$Date)
PM.All$Year <- year(PM.All$Date)
table(PM.All$Year) #woo!

 2002  2022 
15976 57775 
colnames(PM.All)[5] <- "PM2.5"
colnames(PM.All)[7] <- "AQI"
colnames(PM.All)[19] <- "lat"
colnames(PM.All)[20] <- "lon"
3. Create a basic map in leaflet() that shows the locations of the sites (make sure to use different colors for each year). Summarize the spatial distribution of the monitoring sites.

The sites are well distributed between inland and central valley, though there is a paucity of sampling stations in the northern part of the state and in the Mohave Desert/towards the AZ border.

library(leaflet)
library(magrittr)
# Generating a color palette
Year.Pal <- colorBin(c('red','darkblue'), domain=c(2002,2022))
#Make a map
PM.Map <- leaflet(PM.All) %>% 
  addProviderTiles('CartoDB.Positron')   %>%
  addCircles(
    lat = ~lat, lng=~lon,
    label = PM.All$Site.Name, color = ~ Year.Pal(c(2002,2022)),
    opacity = 1, fillOpacity = 1, radius = 500)  %>%
  addLegend('bottomleft', pal=Year.Pal, values = c(2002,2022),
          title='Year', opacity=1)
PM.Map
4. Check for any missing or implausible values of PM2.5 in the combined dataset. Explore the proportions of each and provide a summary of any temporal patterns you see in these observations.

In the combined dataset, the minimum value for PM 2.5 is -2.2, which is not plausible. Negative values represent 0.028% of the combined data. The PM 2.5 >300 is extremely high compared to the rest of the dataset, however this value was found at Siskiyou County on July 31, 2022. According to CalFire, there was a fire in the adjacent Shasta county on 7/14/22, so we’ll keep this value.

By comparing the summary stats, we see that although 2022 had a higher maximum PM 2.5 level, 2022 actually had a lower median daily average PM 2.5 compared to 2002 (12 vs 7).

summary(PM.All$PM2.5)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  -2.20    4.50    7.70   10.21   12.40  302.50 
length(subset(PM.All, PM2.5<0))/nrow(PM.All)*100
[1] 0.02847419
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(furniture)
PM.All %>% 
  group_by(Year) %>% 
  furniture::table1("PM 2.5"= PM2.5)
Using dplyr::group_by() groups: Year

──────────────────────────────
              Year 
        2002        2022     
        n = 15976   n = 57775
 PM 2 5                      
        16.1 (13.9) 8.6 (7.9)
──────────────────────────────
PM.All[which.max(PM.All$PM2.5),]
            Date Source  Site.ID POC PM2.5    UNITS AQI Site.Name
66524 2022-07-31    AQS 60932001   3 302.5 ug/m3 LC 353     Yreka
      DAILY_OBS_COUNT PERCENT_COMPLETE AQS_PARAMETER_CODE
66524               1              100              88101
            AQS_PARAMETER_DESC CBSA_CODE CBSA_NAME STATE_CODE      STATE
66524 PM2.5 - Local Conditions        NA                    6 California
      COUNTY_CODE   COUNTY      lat       lon Year
66524          93 Siskiyou 41.72689 -122.6336 2022
5. Explore the main question of interest at three different spatial levels. Create exploratory plots (e.g. boxplots, histograms, line plots) and summary statistics that best suit each level of data. Be sure to write up explanations of what you observe in these data.

In CA, LA County, and Pasadena, there were higher PM2.5 levels in 2002 than in 2022. The distributions were more skewed in all of CA in 2022, but in Pasadena alone, there was less variation and skew in the PM levels in 2022 compared to 2002.

# CA
boxplot(PM.All$PM2.5 ~ PM.All$Year) #skewed, let's use median

PM.All.Table <- table(PM.All$Year,PM.All$PM2.5)
barplot(PM.All.Table, col = c("red","lightblue"))

tapply(PM.All$PM2.5, PM.All$Year, summary)
$`2002`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00    7.00   12.00   16.12   20.50  104.30 

$`2022`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 -2.200   4.200   7.000   8.574  10.900 302.500 
# LAC
table(PM.All$COUNTY_CODE, PM.All$COUNTY) #37
     
      Alameda Butte Calaveras Colusa Contra Costa Del Norte El Dorado Fresno
  1      1994     0         0      0            0         0         0      0
  7         0  1599         0      0            0         0         0      0
  9         0     0       415      0            0         0         0      0
  11        0     0         0    496            0         0         0      0
  13        0     0         0      0         1097         0         0      0
  15        0     0         0      0            0       568         0      0
  17        0     0         0      0            0         0       436      0
  19        0     0         0      0            0         0         0   3539
  21        0     0         0      0            0         0         0      0
  23        0     0         0      0            0         0         0      0
  25        0     0         0      0            0         0         0      0
  27        0     0         0      0            0         0         0      0
  29        0     0         0      0            0         0         0      0
  31        0     0         0      0            0         0         0      0
  33        0     0         0      0            0         0         0      0
  37        0     0         0      0            0         0         0      0
  39        0     0         0      0            0         0         0      0
  41        0     0         0      0            0         0         0      0
  43        0     0         0      0            0         0         0      0
  45        0     0         0      0            0         0         0      0
  47        0     0         0      0            0         0         0      0
  49        0     0         0      0            0         0         0      0
  51        0     0         0      0            0         0         0      0
  53        0     0         0      0            0         0         0      0
  57        0     0         0      0            0         0         0      0
  59        0     0         0      0            0         0         0      0
  61        0     0         0      0            0         0         0      0
  63        0     0         0      0            0         0         0      0
  65        0     0         0      0            0         0         0      0
  67        0     0         0      0            0         0         0      0
  69        0     0         0      0            0         0         0      0
  71        0     0         0      0            0         0         0      0
  73        0     0         0      0            0         0         0      0
  75        0     0         0      0            0         0         0      0
  77        0     0         0      0            0         0         0      0
  79        0     0         0      0            0         0         0      0
  81        0     0         0      0            0         0         0      0
  83        0     0         0      0            0         0         0      0
  85        0     0         0      0            0         0         0      0
  87        0     0         0      0            0         0         0      0
  89        0     0         0      0            0         0         0      0
  93        0     0         0      0            0         0         0      0
  95        0     0         0      0            0         0         0      0
  97        0     0         0      0            0         0         0      0
  99        0     0         0      0            0         0         0      0
  101       0     0         0      0            0         0         0      0
  103       0     0         0      0            0         0         0      0
  105       0     0         0      0            0         0         0      0
  107       0     0         0      0            0         0         0      0
  111       0     0         0      0            0         0         0      0
  113       0     0         0      0            0         0         0      0
     
      Glenn Humboldt Imperial Inyo Kern Kings Lake Los Angeles Madera Marin
  1       0        0        0    0    0     0    0           0      0     0
  7       0        0        0    0    0     0    0           0      0     0
  9       0        0        0    0    0     0    0           0      0     0
  11      0        0        0    0    0     0    0           0      0     0
  13      0        0        0    0    0     0    0           0      0     0
  15      0        0        0    0    0     0    0           0      0     0
  17      0        0        0    0    0     0    0           0      0     0
  19      0        0        0    0    0     0    0           0      0     0
  21    351        0        0    0    0     0    0           0      0     0
  23      0      175        0    0    0     0    0           0      0     0
  25      0        0     1752    0    0     0    0           0      0     0
  27      0        0        0 2157    0     0    0           0      0     0
  29      0        0        0    0 4135     0    0           0      0     0
  31      0        0        0    0    0   804    0           0      0     0
  33      0        0        0    0    0     0  122           0      0     0
  37      0        0        0    0    0     0    0        7013      0     0
  39      0        0        0    0    0     0    0           0    360     0
  41      0        0        0    0    0     0    0           0      0   573
  43      0        0        0    0    0     0    0           0      0     0
  45      0        0        0    0    0     0    0           0      0     0
  47      0        0        0    0    0     0    0           0      0     0
  49      0        0        0    0    0     0    0           0      0     0
  51      0        0        0    0    0     0    0           0      0     0
  53      0        0        0    0    0     0    0           0      0     0
  57      0        0        0    0    0     0    0           0      0     0
  59      0        0        0    0    0     0    0           0      0     0
  61      0        0        0    0    0     0    0           0      0     0
  63      0        0        0    0    0     0    0           0      0     0
  65      0        0        0    0    0     0    0           0      0     0
  67      0        0        0    0    0     0    0           0      0     0
  69      0        0        0    0    0     0    0           0      0     0
  71      0        0        0    0    0     0    0           0      0     0
  73      0        0        0    0    0     0    0           0      0     0
  75      0        0        0    0    0     0    0           0      0     0
  77      0        0        0    0    0     0    0           0      0     0
  79      0        0        0    0    0     0    0           0      0     0
  81      0        0        0    0    0     0    0           0      0     0
  83      0        0        0    0    0     0    0           0      0     0
  85      0        0        0    0    0     0    0           0      0     0
  87      0        0        0    0    0     0    0           0      0     0
  89      0        0        0    0    0     0    0           0      0     0
  93      0        0        0    0    0     0    0           0      0     0
  95      0        0        0    0    0     0    0           0      0     0
  97      0        0        0    0    0     0    0           0      0     0
  99      0        0        0    0    0     0    0           0      0     0
  101     0        0        0    0    0     0    0           0      0     0
  103     0        0        0    0    0     0    0           0      0     0
  105     0        0        0    0    0     0    0           0      0     0
  107     0        0        0    0    0     0    0           0      0     0
  111     0        0        0    0    0     0    0           0      0     0
  113     0        0        0    0    0     0    0           0      0     0
     
      Mariposa Mendocino Merced Modoc Mono Monterey Nevada Orange Placer Plumas
  1          0         0      0     0    0        0      0      0      0      0
  7          0         0      0     0    0        0      0      0      0      0
  9          0         0      0     0    0        0      0      0      0      0
  11         0         0      0     0    0        0      0      0      0      0
  13         0         0      0     0    0        0      0      0      0      0
  15         0         0      0     0    0        0      0      0      0      0
  17         0         0      0     0    0        0      0      0      0      0
  19         0         0      0     0    0        0      0      0      0      0
  21         0         0      0     0    0        0      0      0      0      0
  23         0         0      0     0    0        0      0      0      0      0
  25         0         0      0     0    0        0      0      0      0      0
  27         0         0      0     0    0        0      0      0      0      0
  29         0         0      0     0    0        0      0      0      0      0
  31         0         0      0     0    0        0      0      0      0      0
  33         0         0      0     0    0        0      0      0      0      0
  37         0         0      0     0    0        0      0      0      0      0
  39         0         0      0     0    0        0      0      0      0      0
  41         0         0      0     0    0        0      0      0      0      0
  43       870         0      0     0    0        0      0      0      0      0
  45         0       823      0     0    0        0      0      0      0      0
  47         0         0    808     0    0        0      0      0      0      0
  49         0         0      0     2    0        0      0      0      0      0
  51         0         0      0     0  806        0      0      0      0      0
  53         0         0      0     0    0     1243      0      0      0      0
  57         0         0      0     0    0        0   1236      0      0      0
  59         0         0      0     0    0        0      0   1352      0      0
  61         0         0      0     0    0        0      0      0   1848      0
  63         0         0      0     0    0        0      0      0      0   1453
  65         0         0      0     0    0        0      0      0      0      0
  67         0         0      0     0    0        0      0      0      0      0
  69         0         0      0     0    0        0      0      0      0      0
  71         0         0      0     0    0        0      0      0      0      0
  73         0         0      0     0    0        0      0      0      0      0
  75         0         0      0     0    0        0      0      0      0      0
  77         0         0      0     0    0        0      0      0      0      0
  79         0         0      0     0    0        0      0      0      0      0
  81         0         0      0     0    0        0      0      0      0      0
  83         0         0      0     0    0        0      0      0      0      0
  85         0         0      0     0    0        0      0      0      0      0
  87         0         0      0     0    0        0      0      0      0      0
  89         0         0      0     0    0        0      0      0      0      0
  93         0         0      0     0    0        0      0      0      0      0
  95         0         0      0     0    0        0      0      0      0      0
  97         0         0      0     0    0        0      0      0      0      0
  99         0         0      0     0    0        0      0      0      0      0
  101        0         0      0     0    0        0      0      0      0      0
  103        0         0      0     0    0        0      0      0      0      0
  105        0         0      0     0    0        0      0      0      0      0
  107        0         0      0     0    0        0      0      0      0      0
  111        0         0      0     0    0        0      0      0      0      0
  113        0         0      0     0    0        0      0      0      0      0
     
      Riverside Sacramento San Benito San Bernardino San Diego San Francisco
  1           0          0          0              0         0             0
  7           0          0          0              0         0             0
  9           0          0          0              0         0             0
  11          0          0          0              0         0             0
  13          0          0          0              0         0             0
  15          0          0          0              0         0             0
  17          0          0          0              0         0             0
  19          0          0          0              0         0             0
  21          0          0          0              0         0             0
  23          0          0          0              0         0             0
  25          0          0          0              0         0             0
  27          0          0          0              0         0             0
  29          0          0          0              0         0             0
  31          0          0          0              0         0             0
  33          0          0          0              0         0             0
  37          0          0          0              0         0             0
  39          0          0          0              0         0             0
  41          0          0          0              0         0             0
  43          0          0          0              0         0             0
  45          0          0          0              0         0             0
  47          0          0          0              0         0             0
  49          0          0          0              0         0             0
  51          0          0          0              0         0             0
  53          0          0          0              0         0             0
  57          0          0          0              0         0             0
  59          0          0          0              0         0             0
  61          0          0          0              0         0             0
  63          0          0          0              0         0             0
  65       5216          0          0              0         0             0
  67          0       3378          0              0         0             0
  69          0          0        597              0         0             0
  71          0          0          0           3733         0             0
  73          0          0          0              0      4497             0
  75          0          0          0              0         0           557
  77          0          0          0              0         0             0
  79          0          0          0              0         0             0
  81          0          0          0              0         0             0
  83          0          0          0              0         0             0
  85          0          0          0              0         0             0
  87          0          0          0              0         0             0
  89          0          0          0              0         0             0
  93          0          0          0              0         0             0
  95          0          0          0              0         0             0
  97          0          0          0              0         0             0
  99          0          0          0              0         0             0
  101         0          0          0              0         0             0
  103         0          0          0              0         0             0
  105         0          0          0              0         0             0
  107         0          0          0              0         0             0
  111         0          0          0              0         0             0
  113         0          0          0              0         0             0
     
      San Joaquin San Luis Obispo San Mateo Santa Barbara Santa Clara
  1             0               0         0             0           0
  7             0               0         0             0           0
  9             0               0         0             0           0
  11            0               0         0             0           0
  13            0               0         0             0           0
  15            0               0         0             0           0
  17            0               0         0             0           0
  19            0               0         0             0           0
  21            0               0         0             0           0
  23            0               0         0             0           0
  25            0               0         0             0           0
  27            0               0         0             0           0
  29            0               0         0             0           0
  31            0               0         0             0           0
  33            0               0         0             0           0
  37            0               0         0             0           0
  39            0               0         0             0           0
  41            0               0         0             0           0
  43            0               0         0             0           0
  45            0               0         0             0           0
  47            0               0         0             0           0
  49            0               0         0             0           0
  51            0               0         0             0           0
  53            0               0         0             0           0
  57            0               0         0             0           0
  59            0               0         0             0           0
  61            0               0         0             0           0
  63            0               0         0             0           0
  65            0               0         0             0           0
  67            0               0         0             0           0
  69            0               0         0             0           0
  71            0               0         0             0           0
  73            0               0         0             0           0
  75            0               0         0             0           0
  77         1173               0         0             0           0
  79            0            1606         0             0           0
  81            0               0       456             0           0
  83            0               0         0          1679           0
  85            0               0         0             0        1651
  87            0               0         0             0           0
  89            0               0         0             0           0
  93            0               0         0             0           0
  95            0               0         0             0           0
  97            0               0         0             0           0
  99            0               0         0             0           0
  101           0               0         0             0           0
  103           0               0         0             0           0
  105           0               0         0             0           0
  107           0               0         0             0           0
  111           0               0         0             0           0
  113           0               0         0             0           0
     
      Santa Cruz Shasta Siskiyou Solano Sonoma Stanislaus Sutter Tehama Trinity
  1            0      0        0      0      0          0      0      0       0
  7            0      0        0      0      0          0      0      0       0
  9            0      0        0      0      0          0      0      0       0
  11           0      0        0      0      0          0      0      0       0
  13           0      0        0      0      0          0      0      0       0
  15           0      0        0      0      0          0      0      0       0
  17           0      0        0      0      0          0      0      0       0
  19           0      0        0      0      0          0      0      0       0
  21           0      0        0      0      0          0      0      0       0
  23           0      0        0      0      0          0      0      0       0
  25           0      0        0      0      0          0      0      0       0
  27           0      0        0      0      0          0      0      0       0
  29           0      0        0      0      0          0      0      0       0
  31           0      0        0      0      0          0      0      0       0
  33           0      0        0      0      0          0      0      0       0
  37           0      0        0      0      0          0      0      0       0
  39           0      0        0      0      0          0      0      0       0
  41           0      0        0      0      0          0      0      0       0
  43           0      0        0      0      0          0      0      0       0
  45           0      0        0      0      0          0      0      0       0
  47           0      0        0      0      0          0      0      0       0
  49           0      0        0      0      0          0      0      0       0
  51           0      0        0      0      0          0      0      0       0
  53           0      0        0      0      0          0      0      0       0
  57           0      0        0      0      0          0      0      0       0
  59           0      0        0      0      0          0      0      0       0
  61           0      0        0      0      0          0      0      0       0
  63           0      0        0      0      0          0      0      0       0
  65           0      0        0      0      0          0      0      0       0
  67           0      0        0      0      0          0      0      0       0
  69           0      0        0      0      0          0      0      0       0
  71           0      0        0      0      0          0      0      0       0
  73           0      0        0      0      0          0      0      0       0
  75           0      0        0      0      0          0      0      0       0
  77           0      0        0      0      0          0      0      0       0
  79           0      0        0      0      0          0      0      0       0
  81           0      0        0      0      0          0      0      0       0
  83           0      0        0      0      0          0      0      0       0
  85           0      0        0      0      0          0      0      0       0
  87         771      0        0      0      0          0      0      0       0
  89           0    755        0      0      0          0      0      0       0
  93           0      0      805      0      0          0      0      0       0
  95           0      0        0    817      0          0      0      0       0
  97           0      0        0      0    442          0      0      0       0
  99           0      0        0      0      0        955      0      0       0
  101          0      0        0      0      0          0    829      0       0
  103          0      0        0      0      0          0      0    347       0
  105          0      0        0      0      0          0      0      0     492
  107          0      0        0      0      0          0      0      0       0
  111          0      0        0      0      0          0      0      0       0
  113          0      0        0      0      0          0      0      0       0
     
      Tulare Ventura Yolo
  1        0       0    0
  7        0       0    0
  9        0       0    0
  11       0       0    0
  13       0       0    0
  15       0       0    0
  17       0       0    0
  19       0       0    0
  21       0       0    0
  23       0       0    0
  25       0       0    0
  27       0       0    0
  29       0       0    0
  31       0       0    0
  33       0       0    0
  37       0       0    0
  39       0       0    0
  41       0       0    0
  43       0       0    0
  45       0       0    0
  47       0       0    0
  49       0       0    0
  51       0       0    0
  53       0       0    0
  57       0       0    0
  59       0       0    0
  61       0       0    0
  63       0       0    0
  65       0       0    0
  67       0       0    0
  69       0       0    0
  71       0       0    0
  73       0       0    0
  75       0       0    0
  77       0       0    0
  79       0       0    0
  81       0       0    0
  83       0       0    0
  85       0       0    0
  87       0       0    0
  89       0       0    0
  93       0       0    0
  95       0       0    0
  97       0       0    0
  99       0       0    0
  101      0       0    0
  103      0       0    0
  105      0       0    0
  107   1731       0    0
  111      0    2710    0
  113      0       0  527
PM.LAC <- subset(PM.All, COUNTY_CODE == "37")
boxplot(PM.LAC$PM2.5 ~ PM.LAC$Year)

PM.LAC.Table <- table(PM.LAC$Year,PM.LAC$PM2.5)
barplot(PM.LAC.Table, col = c("red","lightblue"))

tapply(PM.LAC$PM2.5, PM.LAC$Year, summary)
$`2002`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.60   11.10   17.40   19.66   25.50   72.40 

$`2022`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  -1.20    7.40   10.40   11.04   13.80   56.00 
# Pasadena
table(PM.LAC$Site.ID, PM.LAC$Site.Name) #60372005
          
                Azusa Burbank Compton Glendora Lancaster-Division Street Lebec
  60370002    0   415       0       0        0                         0     0
  60370016    0     0       0       0      365                         0     0
  60371002    0     0     122       0        0                         0     0
  60371103    0     0       0       0        0                         0     0
  60371201    0     0       0       0        0                         0     0
  60371301    0     0       0       0        0                         0     0
  60371302    0     0       0     723        0                         0     0
  60371601  118     0       0       0        0                         0     0
  60371602    0     0       0       0        0                         0     0
  60372005    0     0       0       0        0                         0     0
  60374002    0     0       0       0        0                         0     0
  60374004    0     0       0       0        0                         0     0
  60374008    0     0       0       0        0                         0     0
  60374009    0     0       0       0        0                         0     0
  60374010    0     0       0       0        0                         0     0
  60376012    0     0       0       0        0                         0     0
  60379033    0     0       0       0        0                       459     0
  60379034    0     0       0       0        0                         0   150
          
           Long Beach (North) Long Beach (South) Long Beach-Route 710 Near Road
  60370002                  0                  0                              0
  60370016                  0                  0                              0
  60371002                  0                  0                              0
  60371103                  0                  0                              0
  60371201                  0                  0                              0
  60371301                  0                  0                              0
  60371302                  0                  0                              0
  60371601                  0                  0                              0
  60371602                  0                  0                              0
  60372005                  0                  0                              0
  60374002                411                  0                              0
  60374004                  0                243                              0
  60374008                  0                  0                            625
  60374009                  0                  0                              0
  60374010                  0                  0                              0
  60376012                  0                  0                              0
  60379033                  0                  0                              0
  60379034                  0                  0                              0
          
           Los Angeles-North Main Street Lynwood North Hollywood (NOHO)
  60370002                             0       0                      0
  60370016                             0       0                      0
  60371002                             0       0                      0
  60371103                          1276       0                      0
  60371201                             0       0                      0
  60371301                             0     122                      0
  60371302                             0       0                      0
  60371601                             0       0                      0
  60371602                             0       0                      0
  60372005                             0       0                      0
  60374002                             0       0                      0
  60374004                             0       0                      0
  60374008                             0       0                      0
  60374009                             0       0                      0
  60374010                             0       0                    365
  60376012                             0       0                      0
  60379033                             0       0                      0
  60379034                             0       0                      0
          
           Pasadena Pico Rivera #2 Reseda Santa Clarita Signal Hill (LBSH)
  60370002        0              0      0             0                  0
  60370016        0              0      0             0                  0
  60371002        0              0      0             0                  0
  60371103        0              0      0             0                  0
  60371201        0              0    602             0                  0
  60371301        0              0      0             0                  0
  60371302        0              0      0             0                  0
  60371601        0              0      0             0                  0
  60371602        0            118      0             0                  0
  60372005      241              0      0             0                  0
  60374002        0              0      0             0                  0
  60374004        0              0      0             0                  0
  60374008        0              0      0             0                  0
  60374009        0              0      0             0                293
  60374010        0              0      0             0                  0
  60376012        0              0      0           365                  0
  60379033        0              0      0             0                  0
  60379034        0              0      0             0                  0
PM.PAS <- subset(PM.All, Site.ID == "60372005")
boxplot(PM.PAS$PM2.5 ~ PM.PAS$Year)

PM.PAS.Table <- table(PM.PAS$Year,PM.PAS$PM2.5)
barplot(PM.PAS.Table, col = c("red","lightblue"))

tapply(PM.PAS$PM2.5, PM.PAS$Year, summary)
$`2002`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   4.00   12.00   17.80   20.29   25.20   57.80 

$`2022`
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  3.500   6.400   7.900   9.094  11.575  22.100